home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- References: <272.6650T63T1340@sn.no> <ZZNYYD.96Mar21121908@diku.dk>
- X-Newsreader: MicroDot 1.8
- Mime-version: 1.0
- Content-Type: text/plain; charset=iso-8859-1
- Content-Transfer-encoding: 8BIT
- Path: news.tng.oche.de!tomate.tng.oche.de
- X-Gateway: ZCONNECT UE utomate.tng.oche.de.tomate.tng.oche.de [PolyNet zTOr V4.901 Serie: "light"]
- Subject: Re: Sorting a list
- Message-ID: <xUqu7MD1A7alz7@0dietmar.tomate.tng.oche.de>
- Date: Fri, 22 Mar 96 12:31:39 GMT
- Organization: Developer
- X-ZC-TELEFON: +49-(0)241/81665
- X-ZC-POST: Mies-v-d-Rohe-Str.31 D-52074 Aachen
- From: DIETMAR@TOMATE.TNG.OCHE.DE (Dietmar Eilert)
-
- zznyyd@diku.dk (Finn Nielsen) wrote:
-
- FN> In article <314F9F68.48E2@sapiens.com> Avi Lev <avil@sapiens.com> writes:
- FN> > Christopher Naas wrote:
- FN> > >
- FN> > > What's the absolutely fastest algorithm for sorting a List with around 1000
- FN> > > items alphabetically?
- FN> > >
- FN> >
- FN> > well, the fastest way is no doubt, bubble sort!!! but you have to perform the sort on a
- FN> > list of pointers to the strings not on the strings themselves otherwise it'll be slower.
- FN>
- FN> I really hope you're just kidding here: bubble sort is the slowest sorting
- FN> algorithm ever. ALTO you're right about sorting the pointers instead of the
- FN> [...]
- FN> actual strings. I recommend using QuickSort for sorting the pointers and
-
- You could use a simple modification of bubble sort to boost performance to
- the speed of QuickSort: use a dynamic interval instead of comparing
- neighbours only. In the first pass, you would compare element <a> to
- element <a + distance> and swap them if the order is wrong. Distance is
- reduced after processing all elements. To be continued until the distance
- is <1> (standard bubble sort) and the order is correct.
-
- First pass:
-
- distance = 3 * (elements - 1) / 4
-
- if (distance == 0)
- distance = 1;
-
- Next pass:
-
- if (distance = 3 * distance / 4)
- ready = FALSE;
-
- * In a random sampling of GoldED users, 100% said that they'd rather use
- GoldED than be publically flogged, eaten alive by pirhanas, OR watch
- SeaQuest DSV.
-
- /\/\ GoldED Support: http://www.clearlight.com/~dietmar
- /\/\ E-Mail: dietmar@tomate.tng.oche.de
- /\/\ Fileserver: dietmar@clearlight.com (subject: send file info)
- Phone/FAX: +49-(0)241-81665-(Pause)-22
-
-